﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommunityToolkitDemo.ViewModel
{
    public class ViewModelLocator
    {
        public static IServiceProvider ServiceProvide { get; set; }
        public ViewModelLocator()
        {
            ServiceProvide = GetService();
        }

        private IServiceProvider GetService()
        {
            var service = new ServiceCollection();
            service.AddSingleton<MainViewModel>();
            return service.BuildServiceProvider();
        }
        public MainViewModel Main
        {
            get
            {
                return ServiceProvide.GetService<MainViewModel>();
            }
        }
    }
}
